<template>
  <div class="student-container">
    <van-loading type="spinner" color="#1989fa" v-show="loading" />
    <van-nav-bar fixed left-arrow @click-left="$router.back()" title="你好花开">
    </van-nav-bar>
    <div class="chat-list">
      <!-- 左侧是机器人小智 -->
      <div class="chat-item left">
        <van-image fit="cover" round src="https://img.yzcdn.cn/vant/cat.jpeg" />
        <div class="chat-pao">hi，你好！</div>
      </div>

      <!-- 右侧是当前用户 -->
      <div class="chat-item right">
        <div class="chat-pao my">凌凌漆</div>
        <van-image
          fit="cover"
          round
          src="http://toutiao-img.itheima.net/FltHuWC0FSs_53II1GxPFnI-cVHT"
        />
      </div>
    </div>
    <div class="reply-container van-hairline--top">
      <van-search v-model.trim="word" placeholder="说点什么..." @search="send">
      </van-search>
    </div>
  </div>
</template>

<script>
export default {
  name: 'student',
  data () {
    return {
      loading: true,
      word: ''
    }
  },
  methods: {
    send () {
      console.log(this.word)
    }
  },
  created () {
    setTimeout(() => {
      this.loading = false
    }, 500)
  }
}
</script>

<style lang="less">
.student-container {
  height: 100%;
  width: 100%;
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  background: #fafafa;
  padding: 46px 0 50px 0;
  .van-nav-bar {
    background-color: #3296fa;
    .van-nav-bar__title {
      color: white;
    }
    .van-icon {
      color: white;
    }
  }
  .van-loading {
    position: relative;
    .van-loading__spinner {
      position: fixed;
      top: 50%;
      left: 55%;
      margin-top: -25px;
      margin-left: -25px;
    }
  }
  .chat-list {
    height: 100%;
    overflow-y: scroll;
    .chat-item {
      padding: 10px;
      .van-image {
        vertical-align: top;
        width: 40px;
        height: 40px;
      }
      .chat-pao {
        vertical-align: top;
        display: inline-block;
        min-width: 40px;
        max-width: 70%;
        min-height: 40px;
        line-height: 38px;
        border: 0.5px solid #c2d9ea;
        border-radius: 4px;
        position: relative;
        padding: 0 10px;
        background-color: #e0effb;
        word-break: break-all;
        font-size: 14px;
        color: #333;
        &::before {
          content: '';
          width: 10px;
          height: 10px;
          position: absolute;
          top: 12px;
          border-top: 0.5px solid #c2d9ea;
          border-right: 0.5px solid #c2d9ea;
          background: #e0effb;
        }
      }
      .chat-pao.my {
        background-color: #9eea6a;
        &::before {
          content: '';
          background: #9eea6a;
        }
      }
    }
  }
  .chat-item.right {
    text-align: right;
    .chat-pao {
      margin-left: 0;
      margin-right: 15px;
      &::before {
        right: -6px;
        transform: rotate(45deg);
      }
    }
  }
  .chat-item.left {
    text-align: left;
    .chat-pao {
      margin-left: 15px;
      margin-right: 0;
      &::before {
        left: -5px;
        transform: rotate(-135deg);
      }
    }
  }
  .reply-container {
    position: fixed;
    left: 0;
    bottom: 0;
    height: 44px;
    width: 100%;
    background: #f5f5f5;
    z-index: 9999;
  }
  .van-field {
    border: none;
  }
}
</style>
